package com.pingtai.ajax.service;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import net.sf.json.JSONObject;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.nodes.TagNode;
import org.htmlparser.tags.LinkTag;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;

import com.mysql.jdbc.BufferRow;
import com.pingtai.ajax.dao.NoticeDao;
import com.pingtai.ajax.entity.IndentTarget_163;
import com.pingtai.ajax.entity.Notice;
import com.pingtai.indent.entity.UserIndent;
import com.pingtai.util.ChangeCharset;
import com.pingtai.util.DummyRedirectHandler;
import com.pingtai.util.HttpClientUtils;
import com.pingtai.util.Utils;

public class NoticeService {
	public NoticeDao noticeDao;

	public NoticeDao getNoticeDao() {
		return noticeDao;
	}

	public void setNoticeDao(NoticeDao noticeDao) {
		this.noticeDao = noticeDao;
	}
	
	public Notice getLastNotice(){
		return (Notice) noticeDao.getNotice().get(0);
	}
	
	public IndentTarget_163 getIndentTargetInfo_taobao_dianpu (String targetUrl) throws MalformedURLException, ParserException, IOException{
		URL url;
		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();
		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "gbk");
		Parser parser = Parser.createParser(s, "gbk");
		NodeFilter nameFilter1 = new TagNameFilter("dt");
		NodeFilter nameFilter2 = new HasAttributeFilter("title");
		NodeFilter nameFilter = new AndFilter(nameFilter1,nameFilter2);
		String name = "";
		String num = "";
		String img = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				name = textnode.toPlainTextString();
				name = Utils.NoString(name);
				num = textnode.getNextSibling().getNextSibling().getChildren().elementAt(2).toHtml();
				img = textnode.getParent().getParent().getChildren().elementAt(1).getFirstChild().toHtml();
			}
		}
		
		if(num==null||num.equals("")){
			long l = Utils.getDigit(targetUrl).get(0);
			Parser parser2 = Parser.createParser(s, "gbk");
			nameFilter1 = new TagNameFilter("title");
			nodes = parser2.extractAllNodesThatMatch(nameFilter1);
			if (nodes != null) {
				for (int i = 0; i < nodes.size(); i++) {
					Node textnode = (Node) nodes.elementAt(i);
					name = textnode.toPlainTextString();
				}
			}
			name=name.replace("首页-", "");
			name=name.replace("-淘宝网", "");
			url = new URL("http://count.taobao.com/counter2?keys=SCCP_2_"+l+"&callback=setShopStat");
			urlConnection = url.openConnection();
			inputStream = urlConnection.getInputStream();
			s = ChangeCharset.inputStreamToString(inputStream, "gbk");
			s=s.replace("setShopStat(", "");
			s=s.replace(");", "");
			Map m = Utils.getMapFromJson(s);
			String key = "SCCP_2_"+l;
			num = m.get(key)+"";
			
		}
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setImg(img);
		indentTarget_163.setNumber(num);
		return indentTarget_163;
	}
	
	public IndentTarget_163 getIndentTargetInfo_taobao_tm_gz_timer(String targetUrl,Integer brandId) throws IOException, ParserException{
		URL url;
		String num="-1";
		InputStream inputStream;
		URLConnection urlConnection;
		String s = "";
		if(brandId==null){
			url = new URL(targetUrl);
			urlConnection = url.openConnection();
			inputStream = urlConnection.getInputStream();
			s = ChangeCharset.inputStreamToString(inputStream, "gbk");
			Parser parser2 = Parser.createParser(s, "gbk");
			NodeFilter numFilter = new HasAttributeFilter("class","follow-count");
			NodeList nodes = parser2.extractAllNodesThatMatch(numFilter);
			
			if (nodes != null) {
				for (int i = 0; i < nodes.size(); i++) {
					Node textnode = (Node) nodes.elementAt(i);
					num = textnode.toHtml();
					num = Utils.NoString(num);
				}
			}
		}else{
			url = new URL("http://brand.tmall.com/ajax/getBrandStatusBatch.htm?brandId="+brandId);
			urlConnection = url.openConnection();
			inputStream = urlConnection.getInputStream();
			s = ChangeCharset.inputStreamToString(inputStream, "gbk");
			s = s.replace("(", "");
			s = s.replace(")", "");
			s = s.replace("[", "");
			s = s.replace("]", "");
			Map jsonMap = Utils.getMapFromJson(s);
			Map m = (Map)jsonMap.get("result");
			Integer n = (Integer) m.get("popularity");
			num = n.toString();
		}
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setNumber(num);
		return indentTarget_163;
	}
	
	public IndentTarget_163 getIndentTargetInfo_taobao_tm_gz(String targetUrl) throws IOException, ParserException{
		URL url;
		url = new URL(targetUrl);
		Integer brandId = null;
		URLConnection urlConnection = url.openConnection();
		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "gbk");
		Parser parser = Parser.createParser(s, "gbk");
		NodeFilter nameFilter = new TagNameFilter("title");
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		String name="获取失败";
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				name = textnode.toPlainTextString();
				name = Utils.NoString(name);
			}
		}
		name = name.substring(name.indexOf("-")+1);
		name = name.substring(0,name.indexOf("-"));
		
		
		String num = "-1";
		
			String brandid="-1";
			Parser parser3 = Parser.createParser(s, "gbk");
			NodeFilter brandidFilter = new HasAttributeFilter("data-brandid");
			nodes = parser3.extractAllNodesThatMatch(brandidFilter);
			if (nodes != null) {
				for (int i = 0; i < nodes.size(); i++) {
					
					Node textnode = nodes.elementAt(i);
					if(textnode instanceof LinkTag){
						brandid = ((TagNode) textnode).getAttribute("data-brandid");
					}else{
						continue;
					}
					break;
				}
			}
			
			url = new URL("http://brand.tmall.com/ajax/getBrandStatusBatch.htm?brandId="+brandid);
			urlConnection = url.openConnection();
			inputStream = urlConnection.getInputStream();
			s = ChangeCharset.inputStreamToString(inputStream, "gbk");
			s = s.replace("(", "");
			s = s.replace(")", "");
			s = s.replace("[", "");
			s = s.replace("]", "");
			Map jsonMap = Utils.getMapFromJson(s);
			Map m = (Map)jsonMap.get("result");
			Integer n = (Integer) m.get("popularity");
			brandId = (Integer) m.get("brandId");
			num = n.toString();
		
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setNumber(num);
		indentTarget_163.setBrandId(brandId);
		return indentTarget_163;
	}
	
	public IndentTarget_163 getIndentTargetInfo_taobao_weitao(String targetUrl) throws IOException, ParserException{
		URL url;
		
		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();
		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "gbk");
		Parser parser = Parser.createParser(s, "gbk");
		NodeFilter numFilter = new HasAttributeFilter("class","liner");
		NodeList nodes = parser.extractAllNodesThatMatch(numFilter);
		String num="-1";
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				textnode = textnode.getNextSibling().getNextSibling().getNextSibling();
				num = textnode.toPlainTextString();
				num = Utils.NoString(num);
				num = num.replace("\r\n", "");
				num = num.replace("\n\r", "");
				num = num.replace("\n", "");
				num = num.replace("\r", "");
				num = num.replace("\t", "");
				num = num.replace("粉丝", "");
			}
		}
		
		Parser parser2 = Parser.createParser(s, "gbk");
		NodeFilter nameFilter = new HasAttributeFilter("class","shop-title");
		nodes = parser2.extractAllNodesThatMatch(nameFilter);
		
		String name="-1";
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				//textnode = textnode.getNextSibling();
				name = textnode.toPlainTextString();
				name = Utils.NoString(name);
				break;
			}
		}
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setNumber(num);
		indentTarget_163.setName(name);
		return indentTarget_163;
	}
	
	public IndentTarget_163 getIndentTargetInfo_taobao_baobei(String targetUrl) throws MalformedURLException, ParserException, IOException{
		URL url;
		
		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();
		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "gbk");
		Parser parser = Parser.createParser(s, "gbk");
		NodeFilter nameFilter = new TagNameFilter("title");
		String name = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				name = textnode.toPlainTextString();
				name = Utils.NoString(name);
			}
		}
		Parser imgParser = Parser.createParser(s, "gbk");
		NodeFilter imgFilter = new HasAttributeFilter("id","J_ImgBooth");
		
		String img = "";
		NodeList imgNodes = imgParser.extractAllNodesThatMatch(imgFilter);
		if (imgNodes != null) {
			for (int i = 0; i < imgNodes.size(); i++) {
				Node textnode = (Node) imgNodes.elementAt(i);
				img = textnode.getText() + ">";
				img = Utils.NoString(img);
			}
		}
		img = "<" + img;
		img = img.replace("data-src", "src");
		img = img.replace("310x310", "110x110");
		Map idMap = Utils.URLRequest(targetUrl);
		String id = (String) idMap.get("id");
		url = new URL("http://count.tbcdn.cn/counter3?keys=ICCP_1_"+id+"&callback=num");
		URLConnection urlConnection2 = url.openConnection();
		InputStream inputStream2 = urlConnection2.getInputStream();
		String s2 = ChangeCharset.inputStreamToString(inputStream2, "gbk");
		s2 = s2.replace("num(", "");
		s2 = s2.replace(");", "");
		Map jsonMap = Utils.getMapFromJson(s2);
		String num = (String) jsonMap.get("ICCP_1_"+id).toString();
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setImg(img);
		indentTarget_163.setNumber(num);
		return indentTarget_163;
	}
	
	public IndentTarget_163 getIndentTargetInfo_xinlang_nologin(String targetUrl)throws MalformedURLException, ParserException, IOException{
		URL url;

		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();
		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "utf-8");
		Parser parser = Parser.createParser(s, "UTF-8");
		NodeFilter nameFilter = new HasAttributeFilter("class", "slogan_cont W_Yahei");
		
		String name = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				NodeList l = textnode.getChildren();
				Node n = textnode.getFirstChild();
				name = n.toPlainTextString();
				name = Utils.NoString(name);
				name = name.substring(name.indexOf("我是")+2, name.indexOf("！赶快注册微博粉我吧"));
			}
		}
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		return indentTarget_163;
	}
	public IndentTarget_163 getIndentTargetInfo_xinlang(String targetUrl)
			throws MalformedURLException, ParserException, IOException{
		URL url;

		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();
		
		InputStream inputStream = urlConnection.getInputStream();
		if(urlConnection.getURL().getPath().indexOf("notfound")>0){
			throw new IOException();
		}
		String s = ChangeCharset.inputStreamToString(inputStream, "utf-8");
		
		Parser parser = Parser.createParser(s, "UTF-8");
		NodeFilter nameFilter = new TagNameFilter("title");
		
		String name = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				name = textnode.toPlainTextString();
				name = Utils.NoString(name);
				name = name.substring(0, name.indexOf("的微博|"));
			}
		}
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		return indentTarget_163;
	}
	
	
	public IndentTarget_163 getIndentTarget_163(String targetUrl)
			throws MalformedURLException, ParserException, IOException {
		URL url;

		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();
		
		InputStream inputStream = urlConnection.getInputStream();
		if(urlConnection.getURL().getPath().indexOf("notfound")>0){
			throw new IOException();
		}
		String s = ChangeCharset.inputStreamToString(inputStream, "utf-8");
		
		Parser parser = Parser.createParser(s, "UTF-8");
		NodeFilter nameFilter = new HasAttributeFilter("class", "userBox-name");
		String name = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				NodeList l = textnode.getChildren();
				Node n = textnode.getFirstChild().getNextSibling();
				name = n.toPlainTextString();
				name = Utils.NoString(name);
			}
		}

		NodeFilter imgFilter = new HasAttributeFilter("alt", "/" + name);
		String img = "";
		Parser parser2 = Parser.createParser(s, "UTF-8");
		NodeList imgNodes = parser2.extractAllNodesThatMatch(imgFilter);

		if (imgNodes != null) {
			for (int i = 0; i < imgNodes.size(); i++) {
				Node textnode = (Node) imgNodes.elementAt(i);
				img = textnode.toHtml();
				img = img.replace("amp;", "");
			}
		}
		img = img.replaceAll("\\s{1,}", " ");

		NodeFilter renzhengFilter = new HasAttributeFilter("class",
				"icon-certified");
		String renzheng = "";
		Parser parser3 = Parser.createParser(s, "UTF-8");
		NodeList renzhengList = parser3
				.extractAllNodesThatMatch(renzhengFilter);
		if (renzhengList != null && renzhengList.size() > 0) {
			renzheng = "网易微博 i 认证";
		} else {
			renzheng = "网易普通用户";
		}

		NodeFilter guanzhuFilter = new HasAttributeFilter("id", "followerCount");
		String guanzhu = "";
		Parser parser4 = Parser.createParser(s, "UTF-8");
		NodeList guanzhuList = parser4.extractAllNodesThatMatch(guanzhuFilter);

		if (guanzhuList != null) {
			for (int i = 0; i < guanzhuList.size(); i++) {
				Node textnode = (Node) guanzhuList.elementAt(i);
				guanzhu = textnode.getFirstChild().getNextSibling()
						.getNextSibling().toHtml();
			}
		}

		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setImg(img);
		indentTarget_163.setType(renzheng);
		indentTarget_163.setNumber(guanzhu);
		return indentTarget_163;

	}   
	
	public IndentTarget_163 getIndentTargetInfo_taobao_uz(String targetUrl) throws Exception{
		HttpClient client = HttpClientUtils.getHttpClient();
		HttpGet getMethod = new HttpGet(targetUrl);
		String h = targetUrl.substring(0,targetUrl.indexOf(".uz.taobao.com"));
		h = h.replace("http://", "");
		getMethod.setHeader("Accept-Language","GBK,utf-8;q=0.7,*;q=0.3");  
        getMethod.setHeader("Connection","Keep-Alive"); 
        getMethod.setHeader("Cache-Control","max-age=0"); 
        getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 QIHU 360SE");  
        getMethod.setHeader("Host",h+".uz.taobao.com");  
        //getMethod.setHeader("Cookie","cna=9OWuCmP5cgICAdocUKPtv1Q3; miid=2534829169514643750; jc=sanmenxia; w_sec_step=step_login; __utma=6906807.710473835.1382928840.1382928840.1382928840.1; __utmz=6906807.1382928840.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=%E6%B7%98%E5%AE%9D%20mtop; lzstat_uv=12094129232811459632|2718185@1204781@1580877@3005588@2706027@2535704@2581747@3284827@2581759@2938535@2938538@2312706@2738597; l=mjjsojava::1383898159050::11; s_tn=uAkNeUt2o0L+bW4JU9B2kRpXXes=; _m_h5_tk=3daa08ae612a1d2338719ed0e43ad06e_1384340556884; _m_h5_tk_enc=7f49e6f9662df9963ba813fa11b53b7a; v=0; tg=0; _cc_=Vq8l%2BKCLiw%3D%3D; publishItemObj=Ng%3D%3D; _l_g_=Ug%3D%3D; tracknick=mjjsojava; sg=a16; uc3=nk2=Dlqjy1zGMLYT&id2=Vy0XHPCcKzk%2F&vt3=F8dHqKmZQt82HlSKSWU%3D&lg2=W5iHLLyFOGW7aA%3D%3D; lgc=mjjsojava; existShop=MTM4NDkxNDk4NA%3D%3D; mt=np=&ci=0_1; cookie1=W5%2FQXlekjjHWQ%2FwcUrgpH%2FKqD647C7jeJXTsBZuQg3w%3D; cookie2=dc9206c1d32a4dc14b845e6cafb38461; cookie17=Vy0XHPCcKzk%2F; t=ff968c455b0e716dda3d954e7b438ded; unb=414246401; _nk_=mjjsojava; x=e%3D1%26p%3D*%26s%3D0%26c%3D0%26f%3D0%26g%3D0%26t%3D0; _tb_token_=9gcXv8Wwkm; uc1=lltime=1384822950&cookie14=UoLU721%2BKyq50A%3D%3D&existShop=true&cookie16=V32FPkk%2FxXMk5UvIbNtImtMfJQ%3D%3D&cookie21=U%2BGCWk%2F7oP%2FCuQ%3D%3D&tag=2&cookie15=UtASsssmOIJ0bQ%3D%3D; bid=8");  
        HttpResponse response = client.execute(getMethod);
        InputStream in = response.getEntity().getContent();
        BufferedInputStream bin = new BufferedInputStream(in);
        String msg = Utils.InputStreamTOString(in, "GBK");
        String appId="";
        String appSiteUserId = "";
        String developerId = "";
        String siteId = "";
        String siteName = "";
        String num = "";
        Parser parser = Parser.createParser(msg, "GBK");
        NodeFilter filter = new AndFilter(new TagNameFilter("meta"),
        		new HasAttributeFilter("name","snsplugin-data"));
        NodeList list = parser.extractAllNodesThatMatch(filter);
        if (list != null) {
			for(int i=0;i<list.size();i++){
				Node textnode = (Node) list.elementAt(i);
				String a = textnode.toHtml();
				a = a.substring(a.indexOf("content=\"")+9,a.indexOf("\"/>"));
				a = a.replace(";", "&");
				Map m = Utils.URLRequest(a);
				appId = (String) m.get("appId");
				appSiteUserId = (String) m.get("appSiteUserId");
			}
		}
        
        if(list==null||list.size()==0){
        	filter = new AndFilter(new TagNameFilter("meta"),
            		new HasAttributeFilter("name","microscope-data"));
        	parser = Parser.createParser(msg, "GBK");
        	list = parser.extractAllNodesThatMatch(filter);
            if (list != null) {
    			for(int i=0;i<list.size();i++){
    				Node textnode = (Node) list.elementAt(i);
    				String a = textnode.toHtml();
    				a = a.substring(a.indexOf("content=\"")+9,a.indexOf("\"/>"));
    				a = a.replace(";", "&");
    				Map m = Utils.URLRequest(a);
    				appId = "1100036";
    				appSiteUserId = (String) m.get("userId");
    			}
    		}
        }
        
        msg = msg.substring(msg.lastIndexOf("window.DAOGOU = KISSY.merge(window.DAOGOU"),
        		msg.indexOf("siteDomain"));
        
        msg = msg.replace("window.DAOGOU = KISSY.merge(window.DAOGOU,", "");
        msg = msg.replace("\t", "");
        msg = msg.replace("\n", "");
        msg = msg.replace(" ", "");
        char[] c_a = msg.toCharArray();
        c_a[c_a.length-1] = '}';
        msg = new String(c_a);
        Map m = Utils.getMapFromJson(msg);
        developerId = (String) m.get("developerId");
        siteId = (String) m.get("siteId");
        siteName = (String) m.get("siteName");
        String u = "http://count.tbcdn.cn/counter3?callback=jsonp386&keys=ZAN_27_"+
        		appId+":1_"+appSiteUserId+"_"+siteId;
        getMethod = new HttpGet(u);
		getMethod.setHeader("Accept-Language","GBK,utf-8;q=0.7,*;q=0.3");  
        getMethod.setHeader("Connection","Keep-Alive"); 
        getMethod.setHeader("Cache-Control","max-age=0"); 
        getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 QIHU 360SE");  
        getMethod.setHeader("Host","count.tbcdn.cn");  
        //getMethod.setHeader("Cookie","cna=9OWuCmP5cgICAdocUKPtv1Q3; miid=2534829169514643750; jc=sanmenxia; w_sec_step=step_login; __utma=6906807.710473835.1382928840.1382928840.1382928840.1; __utmz=6906807.1382928840.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=%E6%B7%98%E5%AE%9D%20mtop; lzstat_uv=12094129232811459632|2718185@1204781@1580877@3005588@2706027@2535704@2581747@3284827@2581759@2938535@2938538@2312706@2738597; l=mjjsojava::1383898159050::11; s_tn=uAkNeUt2o0L+bW4JU9B2kRpXXes=; _m_h5_tk=3daa08ae612a1d2338719ed0e43ad06e_1384340556884; _m_h5_tk_enc=7f49e6f9662df9963ba813fa11b53b7a; v=0; tg=0; _cc_=Vq8l%2BKCLiw%3D%3D; publishItemObj=Ng%3D%3D; _l_g_=Ug%3D%3D; tracknick=mjjsojava; sg=a16; uc3=nk2=Dlqjy1zGMLYT&id2=Vy0XHPCcKzk%2F&vt3=F8dHqKmZQt82HlSKSWU%3D&lg2=W5iHLLyFOGW7aA%3D%3D; lgc=mjjsojava; existShop=MTM4NDkxNDk4NA%3D%3D; mt=np=&ci=0_1; cookie1=W5%2FQXlekjjHWQ%2FwcUrgpH%2FKqD647C7jeJXTsBZuQg3w%3D; cookie2=dc9206c1d32a4dc14b845e6cafb38461; cookie17=Vy0XHPCcKzk%2F; t=ff968c455b0e716dda3d954e7b438ded; unb=414246401; _nk_=mjjsojava; x=e%3D1%26p%3D*%26s%3D0%26c%3D0%26f%3D0%26g%3D0%26t%3D0; _tb_token_=9gcXv8Wwkm; uc1=lltime=1384822950&cookie14=UoLU721%2BKyq50A%3D%3D&existShop=true&cookie16=V32FPkk%2FxXMk5UvIbNtImtMfJQ%3D%3D&cookie21=U%2BGCWk%2F7oP%2FCuQ%3D%3D&tag=2&cookie15=UtASsssmOIJ0bQ%3D%3D; bid=8");  
        response = client.execute(getMethod);
        in = response.getEntity().getContent();
        bin = new BufferedInputStream(in);
        msg = Utils.InputStreamTOString(in, "GBK");
        msg = msg.substring(msg.indexOf("\":")+2,msg.lastIndexOf("}"));
        num = msg;
        
        IndentTarget_163 indentTarget = new IndentTarget_163();
        indentTarget.setName(siteName);
        indentTarget.setNumber(num);
        if(in!=null) in.close();
        return indentTarget;
	}
	
	public IndentTarget_163 getIndentTargetInfo_taobao_kt(String targetUrl) throws Exception{
		Map urlParamMap = Utils.URLRequest(targetUrl);
		String item_id = (String) urlParamMap.get("item_id");
		String id = (String) urlParamMap.get("id");
		
		HttpClient client = HttpClientUtils.getHttpClient();
		HttpGet getMethod = new HttpGet("http://skip.ju.taobao.com/json/d/itemDynamic.htm?item_id="+item_id+"&id="+id+"&callback=myjsonp1");
		getMethod.setHeader("Accept-Language","GBK,utf-8;q=0.7,*;q=0.3");  
        getMethod.setHeader("Connection","Keep-Alive"); 
        getMethod.setHeader("Cache-Control","max-age=0"); 
        getMethod.setHeader("Referer","http://ju.taobao.com/tg/home.htm?item_id="+item_id+"&id="+id); 
        getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 QIHU 360SE");  
        getMethod.setHeader("Host","skip.ju.taobao.com");  
        //getMethod.setHeader("Cookie","cna=9OWuCmP5cgICAdocUKPtv1Q3; miid=2534829169514643750; jc=sanmenxia; w_sec_step=step_login; __utma=6906807.710473835.1382928840.1382928840.1382928840.1; __utmz=6906807.1382928840.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=%E6%B7%98%E5%AE%9D%20mtop; lzstat_uv=12094129232811459632|2718185@1204781@1580877@3005588@2706027@2535704@2581747@3284827@2581759@2938535@2938538@2312706@2738597; l=mjjsojava::1383898159050::11; s_tn=uAkNeUt2o0L+bW4JU9B2kRpXXes=; _m_h5_tk=3daa08ae612a1d2338719ed0e43ad06e_1384340556884; _m_h5_tk_enc=7f49e6f9662df9963ba813fa11b53b7a; v=0; tg=0; _cc_=Vq8l%2BKCLiw%3D%3D; publishItemObj=Ng%3D%3D; _l_g_=Ug%3D%3D; tracknick=mjjsojava; sg=a16; uc3=nk2=Dlqjy1zGMLYT&id2=Vy0XHPCcKzk%2F&vt3=F8dHqKmZQt82HlSKSWU%3D&lg2=W5iHLLyFOGW7aA%3D%3D; lgc=mjjsojava; existShop=MTM4NDkxNDk4NA%3D%3D; mt=np=&ci=0_1; cookie1=W5%2FQXlekjjHWQ%2FwcUrgpH%2FKqD647C7jeJXTsBZuQg3w%3D; cookie2=dc9206c1d32a4dc14b845e6cafb38461; cookie17=Vy0XHPCcKzk%2F; t=ff968c455b0e716dda3d954e7b438ded; unb=414246401; _nk_=mjjsojava; x=e%3D1%26p%3D*%26s%3D0%26c%3D0%26f%3D0%26g%3D0%26t%3D0; _tb_token_=9gcXv8Wwkm; uc1=lltime=1384822950&cookie14=UoLU721%2BKyq50A%3D%3D&existShop=true&cookie16=V32FPkk%2FxXMk5UvIbNtImtMfJQ%3D%3D&cookie21=U%2BGCWk%2F7oP%2FCuQ%3D%3D&tag=2&cookie15=UtASsssmOIJ0bQ%3D%3D; bid=8");  
        HttpResponse response = client.execute(getMethod);
        InputStream in = response.getEntity().getContent();
        BufferedInputStream bin = new BufferedInputStream(in);
        String msg = Utils.InputStreamTOString(in, "GBK");
        msg = msg.replace("myjsonp1(", "");
        msg = msg.replace(")", "");
        Map numMap = Utils.getMapFromJson(msg);
        Map data = (Map) numMap.get("data");
        String num = (String) data.get("remindNum");
        getMethod = new HttpGet(targetUrl);
        getMethod.setHeader("Accept-Language","GBK,utf-8;q=0.7,*;q=0.3");  
        getMethod.setHeader("Connection","Keep-Alive"); 
        getMethod.setHeader("Cache-Control","max-age=0"); 
        getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 QIHU 360SE");  
        getMethod.setHeader("Host","ju.taobao.com");  
        response = client.execute(getMethod);
        in = response.getEntity().getContent();
        bin = new BufferedInputStream(in);
        msg = Utils.InputStreamTOString(in, "GBK");
        Parser parser = Parser.createParser(msg, "GBK");
		NodeFilter nameFilter = new HasAttributeFilter("class","name");
		String name = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				name = textnode.toHtml();
				name = Utils.NoString(name);
			}
		}
        
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setNumber(num);
		
		if(in!=null) in.close();
		
		return indentTarget_163;
	}
	
	public IndentTarget_163 getIndentTargetInfo_qq(String targetUrl)
			throws IOException, ParserException {
		
		String uid = "";
	 	if(targetUrl.substring(targetUrl.length()-1).equals("/")){
	 		targetUrl = targetUrl.substring(0, targetUrl.length()-1);
	 		uid = targetUrl.substring(targetUrl.lastIndexOf("/")+1);
	 	}else{
	 		uid = targetUrl.substring(targetUrl.lastIndexOf("/")+1);
	 	}
	 	targetUrl = "http://t.qq.com/"+uid;
		
		URL url;
		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();

		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "utf-8");

		Parser parser = Parser.createParser(s, "utf-8");
		NodeFilter nameFilter = new TagNameFilter("title");
		String name = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				NodeList l = textnode.getChildren();
				Node n = textnode.getFirstChild();
				name = n.toHtml();
				name = Utils.NoString(name);
			}
		}

		name = name.substring(0, name.indexOf("的"));
		NodeFilter imgFilter = new HasAttributeFilter("alt", name);
		String img = "";
		Parser parser2 = Parser.createParser(s, "UTF-8");
		NodeList imgNodes = parser2.extractAllNodesThatMatch(imgFilter);

		if (imgNodes != null) {
			for (int i = 0; i < imgNodes.size(); i++) {
				Node textnode = (Node) imgNodes.elementAt(i);
				img = textnode.toHtml();
				img = img.replace("amp;", "");
			}
		}

		NodeFilter guanzhuFilter = new HasAttributeFilter("boss", "btnApolloFollower");
		String guanzhu = "";
		Parser parser4 = Parser.createParser(s, "UTF-8");
		NodeList guanzhuList = parser4.extractAllNodesThatMatch(guanzhuFilter);

		if (guanzhuList != null) {
			for (int i = 0; i < guanzhuList.size(); i++) {
				Node textnode = (Node) guanzhuList.elementAt(i);
				guanzhu = textnode.getFirstChild().getFirstChild().toHtml();
				Integer c = null;
				try {
					c = new Integer(guanzhu);
				} catch (Exception e) {
					continue;
				}
				if (c != null)
					break;
			}

		}
		if(guanzhu==null||guanzhu.equals("")){
			guanzhuFilter = new HasAttributeFilter("class", "followerNum");
			Parser parser5 = Parser.createParser(s, "UTF-8");
			guanzhuList = parser5.extractAllNodesThatMatch(guanzhuFilter);

			if (guanzhuList != null) {
				for (int i = 0; i < guanzhuList.size(); i++) {
					Node textnode = (Node) guanzhuList.elementAt(i);
					guanzhu = textnode.toPlainTextString();
					Integer c = null;
					try {
						c = new Integer(guanzhu);
					} catch (Exception e) {
						continue;
					}
					if (c != null)
						break;
				}

			}
		}
		
		if(guanzhu==null||guanzhu.equals("")){
			guanzhuFilter = new HasAttributeFilter("class", "text_count co_c_tx");
			Parser parser6 = Parser.createParser(s, "UTF-8");
			guanzhuList = parser6.extractAllNodesThatMatch(guanzhuFilter);
			
			if (guanzhuList != null) {
					Node textnode = (Node) guanzhuList.elementAt(0);
					guanzhu = textnode.toPlainTextString();
					Integer c = null;
					try {
						c = new Integer(guanzhu);
					} catch (Exception e) {
						e.printStackTrace();
					}
			}
		}

		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setImg(img);
		indentTarget_163.setNumber(guanzhu);
		return indentTarget_163;
	}

		
	
    public IndentTarget_163 getIndentTargetInfo_qq_zbpl(String targetUrl) throws IOException, ParserException{
    	URL url;

		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();

		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "utf-8");

		Parser parser = Parser.createParser(s, "utf-8");
		NodeFilter msgFilter = new HasAttributeFilter("id","qzShareCont");
		String msg = "";
		NodeList nodes = parser.extractAllNodesThatMatch(msgFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				 Node textnode = (Node) nodes.elementAt(i);
	              NodeList l = textnode.getChildren();
	              Node n = textnode.getFirstChild();
	              msg=n.toHtml();
	              msg = Utils.NoString(msg);
			}
		}
		
		String aid = targetUrl.replace("http://t.qq.com/p/t/", "");
		String zbUrlStr = "http://api.t.qq.com/old/message.php?id="+aid+"&format=1&filter=5";
		
		URL zbUrl = new URL(zbUrlStr);
		URLConnection zbUrlConnection = zbUrl.openConnection();
		InputStream zbInputStream = zbUrlConnection.getInputStream();
		String zbS = ChangeCharset.inputStreamToString(zbInputStream, "utf-8");
		zbS = Utils.unicodeToString(zbS);
		JSONObject jsonObject = JSONObject.fromObject(zbS);
		zbS = (String) jsonObject.get("info");
		
		Parser zbParser = Parser.createParser(zbS, "utf-8");
		NodeFilter zbFilter = new HasAttributeFilter("class","select");
		String zbNumber="";
		NodeList zbNodes = zbParser.extractAllNodesThatMatch(zbFilter);
		if(zbNodes!=null) {
          for (int i = 0; i < zbNodes.size(); i++) {
              Node textnode = (Node) zbNodes.elementAt(i);
              NodeList l = textnode.getChildren();
              Node n = textnode.getFirstChild();
              zbNumber=n.toHtml();
              zbNumber = Utils.NoString(zbNumber);
              zbNumber = zbNumber.replace("转播", "");
              zbNumber = zbNumber.replace("(", "");
              zbNumber = zbNumber.replace(")", "");
          }
      } 
		
		String plUrlStr = "http://api.t.qq.com/old/message.php?id="+aid+"&format=1&filter=6";
		
		URL plUrl = new URL(plUrlStr);
		URLConnection plUrlConnection = plUrl.openConnection();
		InputStream plInputStream = plUrlConnection.getInputStream();
		String plS = ChangeCharset.inputStreamToString(plInputStream, "utf-8");
		plS = Utils.unicodeToString(plS);
		jsonObject = JSONObject.fromObject(plS);
		plS = (String) jsonObject.get("info");
		
		Parser plParser = Parser.createParser(plS, "utf-8");
		NodeFilter plFilter = new HasAttributeFilter("class","select");
		String plNumber="";
		NodeList plNodes = plParser.extractAllNodesThatMatch(plFilter);
		if(plNodes!=null) {
          for (int i = 0; i < plNodes.size(); i++) {
              Node textnode = (Node) plNodes.elementAt(i);
              NodeList l = textnode.getChildren();
              Node n = textnode.getFirstChild();
              plNumber=n.toHtml();
              plNumber = Utils.NoString(plNumber);
              plNumber = plNumber.replace("评论", "");
              plNumber = plNumber.replace("(", "");
              plNumber = plNumber.replace(")", "");
          }
      }
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
        indentTarget_163.setMsg(msg);
        indentTarget_163.setPlNumber(plNumber);
        indentTarget_163.setZbNumber(zbNumber);
        return indentTarget_163;
    }
    
    public IndentTarget_163 getIndentTargetInfo_xl_blog_fw(String targetUrl) throws Exception{
    	HttpClient client = null;
    	String name="";
    	String uid="";
		client = HttpClientUtils.getHttpClient();
		
		HttpGet getMethod = new HttpGet(targetUrl);
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","zh-CN,zh;q=0.8");  
		getMethod.setHeader("Connection","Keep-Alive");  
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");  
		getMethod.setHeader("Host","blog.sina.com.cn"); 
		HttpResponse response = client.execute(getMethod);
		InputStream in = response.getEntity().getContent();
		String msg = Utils.InputStreamTOString(in, "utf-8");
		
		Parser parser = Parser.createParser(msg, "utf-8");
		NodeFilter filter = new HasAttributeFilter("id", "ownernick");
		NodeList list = parser.extractAllNodesThatMatch(filter);
		
		if (list != null) {
			for(int i=0;i<list.size();i++){
				Node textnode = (Node) list.elementAt(i);
				String a = textnode.getNextSibling().getText();
				a = a.replace("\t", "");
				a = a.replace("\n", "");
				name=a;
			}
		}
		
		Parser parser2 = Parser.createParser(msg, "utf-8");
		filter = new HasAttributeFilter("class", "blogzz_zzlist borderc");
		list = parser2.extractAllNodesThatMatch(filter);
		

		if (list != null) {
			for(int i=0;i<list.size();i++){
				Node textnode = (Node) list.elementAt(i);
				String a = textnode.toHtml();
				a = a.substring(a.indexOf("id=\"ff_")+7,a.indexOf("id=\"ff_")+15);
				uid=a;
				break;
			}
		}
		
		getMethod = new HttpGet("http://hits.blog.sina.com.cn/hits?act=3&uid=5cebc8b2&ref=http%3A%2F%2Fblog.sina.com.cn%2Ffeng22222&varname=requestId_69977178");
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","zh-CN,zh;q=0.8");  
		getMethod.setHeader("Connection","Keep-Alive");  
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");
		getMethod.setHeader("Referer","http://blog.sina.com.cn/feng22222");
		getMethod.setHeader("Host","hits.blog.sina.com.cn"); 
		response = client.execute(getMethod);
		in = response.getEntity().getContent();
		msg = Utils.InputStreamTOString(in, "utf-8");
//		System.out.println(msg);
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		return indentTarget_163;
    }
    
    public IndentTarget_163 getIndentTargetInfo_xl_blog_gz(String targetUrl) throws Exception{
    	HttpClient client = null;
    	String name="";
    	String uid="";
		client = HttpClientUtils.getHttpClient();
		
		HttpGet getMethod = new HttpGet(targetUrl);
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","zh-CN,zh;q=0.8");  
		getMethod.setHeader("Connection","Keep-Alive");  
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");  
		getMethod.setHeader("Host","blog.sina.com.cn"); 
		HttpResponse response = client.execute(getMethod);
		InputStream in = response.getEntity().getContent();
		String msg = Utils.InputStreamTOString(in, "utf-8");
		
		Parser parser = Parser.createParser(msg, "utf-8");
		NodeFilter filter = new HasAttributeFilter("id", "ownernick");
		NodeList list = parser.extractAllNodesThatMatch(filter);
		
		if (list != null) {
			for(int i=0;i<list.size();i++){
				Node textnode = (Node) list.elementAt(i);
				String a = textnode.getNextSibling().getText();
				a = a.replace("\t", "");
				a = a.replace("\n", "");
				name=a;
			}
		}
		Parser parser2 = Parser.createParser(msg, "utf-8");
		filter = new HasAttributeFilter("title", "RSS");
		list = parser2.extractAllNodesThatMatch(filter);
		

		if (list != null) {
			for(int i=0;i<list.size();i++){
				Node textnode = (Node) list.elementAt(i);
				String a = textnode.toHtml();
				a=a.substring(a.indexOf("http://blog.sina.com.cn/rss/")+28,a.lastIndexOf(".xml"));
				uid=a;
			}
		}
		
		String num_url = "http://blogtj.sinajs.cn/api/get_attention_num.php?uid="+
						 uid+"&suid=0&attention=suid&userpointuid="+uid+"&varname=requestId_0";
		getMethod = new HttpGet(num_url);
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","zh-CN,zh;q=0.8");  
		getMethod.setHeader("Connection","Keep-Alive");  
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");  
		getMethod.setHeader("Host","blogtj.sinajs.cn"); 
		response = client.execute(getMethod);
		in = response.getEntity().getContent();
		msg = Utils.InputStreamTOString(in, "utf-8");
		msg = msg.replace("requestId_0=", "");
		Map root = Utils.getMapFromJson(msg);
		Map sec = (Map) root.get("data");
		Integer num = (Integer) sec.get(uid);
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setNumber(num.toString());
		return indentTarget_163;
    }
    
    public IndentTarget_163 getIndentTargetInfo_sohu(String targetUrl) throws IOException, ParserException{
    	URL url;
		url = new URL(targetUrl);
		URLConnection urlConnection = url.openConnection();
		
		InputStream inputStream = urlConnection.getInputStream();
		String s = ChangeCharset.inputStreamToString(inputStream, "gbk");
		Parser parser = Parser.createParser(s, "gbk");
		NodeFilter nameFilter = new  HasAttributeFilter("id", "username");
		String name = "";
		NodeList nodes = parser.extractAllNodesThatMatch(nameFilter);
		if (nodes != null) {
			for (int i = 0; i < nodes.size(); i++) {
				Node textnode = (Node) nodes.elementAt(i);
				Node l = textnode.getNextSibling();
				name = l.toHtml();
				name = Utils.NoString(name);
			}
		}
		
		NodeFilter imgFilter = new HasAttributeFilter("alt", name);
		String img = "";
		Parser parser2 = Parser.createParser(s, "gbk");
		NodeList imgNodes = parser2.extractAllNodesThatMatch(imgFilter);

		if (imgNodes != null) {
			for (int i = 0; i < imgNodes.size(); i++) {
				Node textnode = (Node) imgNodes.elementAt(i);
				img = textnode.toHtml();
				img = img.replace("amp;", "");
			}
		}
		
		NodeFilter guanzhuFilter = new HasAttributeFilter("id","hrefFans");
		String guanzhu = "";
		Parser parser4 = Parser.createParser(s, "UTF-8");
		NodeList guanzhuList = parser4.extractAllNodesThatMatch(guanzhuFilter);

		if (guanzhuList != null) {
			for(int i=0;i<guanzhuList.size();i++){
				Node textnode = (Node) guanzhuList.elementAt(i);
				NodeList l = textnode.getParent().getChildren();
				guanzhu = l.elementAt(7).toHtml();
				Integer c = null;
				try {
					 c = new Integer(guanzhu);
				} catch (Exception e) {
					continue;
				}
				if(c!=null) break;
			}
		}
		
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setName(name);
		indentTarget_163.setImg(img);
		indentTarget_163.setNumber(guanzhu);
		return indentTarget_163;
    }
    
    public IndentTarget_163 getIndentTargetInfo_qq_kj_fan(String url) throws Exception{
		HttpClient client = null;
		client = HttpClientUtils.getHttpClient();
		
		List uidList = Utils.getDigit(url);
		String uid = "";
		if(uidList!=null&&uidList.size()>0){
			Long l =  (Long) uidList.get(0);
			uid = l.toString();
		}
		HttpGet getMethod2 = new HttpGet("http://r.qzone.qq.com/cgi-bin/tfriend/cgi_like_check_and_getfansnum.cgi?uin="+uid+"&mask=3");
		getMethod2.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod2.setHeader("Accept-Language","zh-CN,zh;q=0.8");  
		getMethod2.setHeader("Connection","Keep-Alive");  
		getMethod2.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");  
		getMethod2.setHeader("Host","r.qzone.qq.com");  
		HttpResponse response = client.execute(getMethod2);
		InputStream in = response.getEntity().getContent();
		BufferedInputStream bin = new BufferedInputStream(in);
        String msg = Utils.InputStreamTOString(in, "utf-8");
		msg = Utils.unicodeToString(msg);
		msg = msg.replace("_Callback(", "");
		msg = msg.replace(");", "");
		Map m = Utils.getMapFromJson(msg);
		Map m2 = (Map) m.get("data");
		Integer num = (Integer) m2.get("total");
		IndentTarget_163 indentTarget_163 = new IndentTarget_163();
		indentTarget_163.setNumber(num.toString());
		if(in!=null) in.close();
		return indentTarget_163;
	}
    
    public boolean checkRenzheng_xl_change(String url,UserIndent indent) throws ClientProtocolException, IOException, ParserException{
    	String remark = indent.getRenzheng().getXinlangPersonRenzheng().getRemark();
    	HttpClient client = null;
		client = new DefaultHttpClient();
		HttpGet getMethod = new HttpGet(url);
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","utf-8;q=0.8");  
		getMethod.setHeader("Connection","Keep-Alive");  
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 QIHU 360SE");  
		getMethod.setHeader("Host","weibo.com");  
		HttpResponse response = client.execute(getMethod);
		InputStream in = response.getEntity().getContent();
		BufferedInputStream bin = new BufferedInputStream(in);
		BufferedReader reader = new BufferedReader(new InputStreamReader(bin));
		 String msg = "";
	        while(reader.read()!=-1){
	        	String s = reader.readLine();
	        	if(s.indexOf("FM.view({\"ns\":\"pl.header.head.index\"")!=-1){
	        		msg = s;
	        		break;
	        	}
	        }
	        
			msg = ChangeCharset.changeCharset(msg, "utf-8");
			msg = msg.replace("script>FM.view(", "");
			msg = msg.replace("<script>FM.view(", "");
			msg = msg.replace(")</script>", "");
			
			Map dataMap = Utils.getMapFromJson(msg);
			String html = (String) dataMap.get("html");
			html = ChangeCharset.changeCharset(html, "gb2312");
			Parser parser = Parser.createParser(html, "gb2312");
			
			NodeFilter filter = new HasAttributeFilter("class","pf_verified_info bsp S_txt2");
			NodeList list = parser.extractAllNodesThatMatch(filter);
			

			if (list != null) {
				for(int i=0;i<list.size();i++){
					Node textnode = (Node) list.elementAt(i);
					String a = textnode.toPlainTextString();
				}
			}
			
			if(in!=null) in.close();
			
			if(html.indexOf(remark)!=-1){
				return true;
			}
			return false;
    }
	
    public boolean checkRenzheng_tx_persion(String url) throws Exception{
    	boolean b = false;
    	HttpClient client = null;
		client = HttpClientUtils.getHttpClient();
		HttpGet getMethod = new HttpGet(url);
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","zh-CN,zh;q=0.8");
		getMethod.setHeader("Accept-Charset","GBK,utf-8;q=0.7,*;q=0.3"); 
		getMethod.setHeader("Connection","Keep-Alive");  
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");  
		getMethod.setHeader("Host","t.qq.com");  
		HttpResponse response = client.execute(getMethod);
		InputStream in = response.getEntity().getContent();
		String msg = Utils.InputStreamTOString(in, "utf-8");
		Parser parser = Parser.createParser(msg, "utf-8");
		NodeFilter filter = new HasAttributeFilter("class", "tit");
		NodeList list = parser.extractAllNodesThatMatch(filter);
		

		if (list != null) {
			for(int i=0;i<list.size();i++){
				Node textnode = (Node) list.elementAt(i);
				String a = textnode.toHtml();
				if(a.indexOf("腾讯个人认证")!=-1){
					b=true;
					break;
				}
			}
		}
		if(in!=null) in.close();
		return b;
	      
    }
    
    public boolean checkRenzheng_tx_qy(String url) throws Exception{
    	boolean b = false;
    	AbstractHttpClient client = null;
		client = (AbstractHttpClient) HttpClientUtils.getHttpClient();
		client.setRedirectHandler(new DummyRedirectHandler());
		HttpGet getMethod = new HttpGet(url);
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","zh-CN,zh;q=0.8");
		getMethod.setHeader("Accept-Charset","GBK,utf-8;q=0.7,*;q=0.3"); 
		getMethod.setHeader("Connection","keep-alive"); 
		getMethod.setHeader("Cache-Control","max-age=0"); 
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");  
		getMethod.setHeader("Host","t.qq.com");  
		HttpResponse response = client.execute(getMethod);
		Header[] header = response.getAllHeaders();
		String location=null;
		for(int i=0;i<header.length;i++){
			Header h = header[i];
			String headerName = h.getName();
			String headerValue = h.getValue();
			if(headerName.equals("Location")){
				location = headerValue;
				break;
			}
		}
		response.getEntity().getContent().close();
		if(location==null) return false;
		if(location.indexOf("e.t.qq.com")!=-1) return true;
		return b;
		
//		
//		InputStream in = response.getEntity().getContent();
//		String msg = Utils.InputStreamTOString(in, "utf-8");
//		Parser parser = Parser.createParser(msg, "utf-8");
//		NodeFilter filter = new HasAttributeFilter("class", "tit");
//		NodeList list = parser.extractAllNodesThatMatch(filter);
//		
//
//		if (list != null) {
//			for(int i=0;i<list.size();i++){
//				Node textnode = (Node) list.elementAt(i);
//				String a = textnode.toHtml();
//				if(a.indexOf("腾讯机构认证")!=-1){
//					b=true;
//					break;
//				}
//			}
//		}
//		
//		return b;
	      
    }
    
	public boolean checkRenzheng_xl(String url) throws ClientProtocolException, IOException, ParserException{
		HttpClient client = null;
		client = HttpClientUtils.getHttpClient();
		HttpGet getMethod = new HttpGet(url);
		getMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");  
		getMethod.setHeader("Accept-Language","zh-CN,zh;q=0.8");  
		getMethod.setHeader("Connection","Keep-Alive");  
		getMethod.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");  
		getMethod.setHeader("Host","weibo.com");  
		HttpResponse response = client.execute(getMethod);
		InputStream in = response.getEntity().getContent();
		BufferedInputStream bin = new BufferedInputStream(in);
		BufferedReader reader = new BufferedReader(new InputStreamReader(bin));
		
		 String msg = "";
	        while(reader.read()!=-1){
	        	String s = reader.readLine();
	        	if(s.indexOf("FM.view({\"ns\":\"pl.header.head.index\"")!=-1){
	        		msg = s;
	        		break;
	        	}
	        }
			msg = Utils.unicodeToString(msg);
			if(in!=null) in.close();
			if(msg.indexOf("sinaVIP.png")!=-1){
				return true;
			}
			return false;
	}
    
}
